package cn.edu.scau.cmi.wujingxuan.composite.safe;

import java.util.ArrayList;
import java.util.Iterator;

public class Composite extends Organization
{
	private ArrayList<Organization> PersonList;
	private String word = "";

	public Composite()
	{
		PersonList = new ArrayList<Organization>();
	}

	public void add(Organization person)
	{
		if (person != null)
		{
			PersonList.add(person);
		}
	}

	public void remove(Organization person)
	{
		if (person != null)
		{
			PersonList.remove(person);
		}
	}

	public Iterator<Organization> elements()
	{
		return PersonList.iterator();
	}

	public String say()
	{
		int len = PersonList.size();
		for (int i = 0; i < len; i++)
		{
			Organization ctry = PersonList.get(i);
			word = word + ctry.say() + "\n";
		}
		return word;
	}

	public int getSize()
	{
		return PersonList.size();
	}
}
